<html>
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <#assign base=request.contextPath  />
    <#setting  number_format="0.##"/>
    <title>订单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${base}/backstage/layui/css/layui.css" media="all">
    <script src="${base}/backstage/js/jquery-1.8.3.min.js"></script>
    <script src="${base}/backstage/layui/layui.js"></script>
    <script src="${base}/backstage/js/feng.js"></script>
    <script>
        var base =  "${base}";
    </script>
    <script src="${base}/backstage/js/ipNameUrl.js"></script>
    <style>
        /*给数据表格加高*/
        .layui-table-cell{
            height:50%;
        }
    </style>
</head>
<body>
<br>
<div class="demoTable" style="margin-left: 15px;">
    <form class="layui-form " action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label>订单号</label>
                <div class="layui-inline">
                    <input class="layui-input" name="oddNumber" id="oddNumber" placeholder="请输入订单号" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label>联系电话</label>
                <div class="layui-inline">
                    <input class="layui-input" name="phone" id="phone" placeholder="请输入联系电话" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">订单状态</label>
                <div class="layui-input-inline">
                    <select name="modules" id="state" lay-verify="required" lay-search="">
                        <option value="">请选择订单状态</option>
                        <option value="1">已支付</option>
                        <option value="2">未支付</option>
                        <option value="3">退货/售后</option>
                        <option value="4">待发货</option>
                        <option value="5">待收货</option>
                        <option value="6">已发货</option>
                        <option value="7">已完成</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">签收状态</label>
                <div class="layui-input-inline">
                    <select name="modules" id="type" lay-verify="required" lay-search="">
                        <option value="">请选择签收状态</option>
                        <option value="1">已签收</option>
                        <option value="2">未签收</option>
                    </select>
                </div>
            </div>
            <button class="layui-btn" onclick="sech()" data-method="offset"
                    type="button">查询
            </button>
        </div>
    </form>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="barDemo">

    {{#  if(d.state ==4){ }}
    <button data-method="offset" data-type="auto" class="layui-btn layui-btn-normal" onclick="KD('{{d.id}}')">填写单号</button>
    {{#  } }}
    {{#  if(d.state ==6){ }}
    <button data-method="offset" data-type="auto" class="layui-btn">已发货</button>
    <button data-method="offset" data-type="auto" class="layui-btn layui-btn-warm" onclick="showKD('{{d.kdNumber}}')">查看快递</button>
    {{#  } }}
    {{#  if(d.state ==7){ }}
    <button data-method="offset" data-type="auto" class="layui-btn">已完成</button>
    {{#  } }}



</script>

<script>
    layui.use(['table', 'form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , $ = layui.jquery
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , table = layui.table;

        var whereData = {}
        whereData.oddNumber = $("#oddNumber").val();
        whereData.phone = $("#phone").val();
        whereData.state = $("#state").val();
        whereData.type = $("#type").val();

        table.render({
            skin: 'line' //行边框风格
            , even: true //开启隔行背景
            , elem: '#test'
            ,where:whereData
            , url: '${base}/admin/shoppingOrder/selectMyPage'
            , toolbar: '#toolbarDemo'
            ,cols:[[
                {field:'id', title: '序号',templet:function(val){
                        return val.LAY_INDEX
                    },align:'center'},
                {field:'oddNumber', title: '订单号', align:'center'},
                {field:'phone', title: '用户', align:'center'},
                {field:'goodName', title: '商品名称', align:'center'},
                {field:'price', title: '商品单价', align:'center'},
                {field:'color', title: '颜色', align:'center'},
                {field:'size', title: '尺码', align:'center'},
                {field:'sum', title: '数量', align:'center'},
                {field:'sumPrice', title: '支付金额', align:'center'},

                {field:'state', title: '订单状态',templet:function(val){
                        if(val.state==undefined){
                            return "";
                        }
                        if(val.state==1){
                            return "已支付";
                        }
                        if(val.state==2){
                            return "未支付";
                        }
                        if(val.state==3){
                            return "退货/售后";
                        }
                        if(val.state==4){
                            return "待发货";
                        }
                        if(val.state==5){
                            return "待收货";
                        }
                        if(val.state==6){
                            return "已发货";
                        }
                        if(val.state==7){
                            return "已完成";
                        }
                    }, align:'center'},
                {field:'kdNumber', title: '快递单号', align:'center'},
                {field:'type', title: '签收状态',templet:function(val){
                        if(val.type==undefined){
                            return "";
                        }
                        if(val.type==1){
                            return "已签收";
                        }
                        if(val.type==2){
                            return "未签收";
                        }

                    },  align:'center'},
                {field:'signTime', title: '签收日期',templet:function(val){
                        if(val.signTime==undefined){
                            return "";
                        }
                        return changeDateFormat(val.signTime);
                    }, align:'center'},
                {field:'createTime', title: '创建时间',templet:function(val){
                        if(val.createTime==undefined){
                            return "";
                        }
                        return changeDateFormat(val.createTime);
                    },  align:'center'},
                {field: 'right', title: '操作',width:220, toolbar: '#barDemo', align: 'center'}
            ]]
            , id: 'testReload'
            , page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                , theme: '#1AB394'
                , limit: 10
            }
        });

        //添加
        var active = {
            offset: function (othis) {
                var type = othis.data('type')
                    , text = othis.text();
                window.location.href = '${base}/admin/wheelPlanting/wheelPlanting_add.html';
            }
        };
        $('#btn2').on('click', function () {
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });

        //编辑弹出层
        <#--table.on('tool(test)', function (obj) {-->
        <#--    var layEvent = obj.event;-->
        <#--    if (layEvent == "edit") {-->
        <#--        var data = obj.data;-->
        <#--        window.location.href = '${base}/admin/shoppingOrder/oddNumber.html?id=' ;-->
        <#--    }-->
        <#--});-->

    })
    
    function KD(id) {
        layer.open({
            type: 2
            ,title: false //不显示标题栏
            ,closeBtn: false
            ,area: '300px;'
            ,shade: 0.8
            ,area:['400px','150px']
            ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
            ,btnAlign: 'c'
            ,moveType: 1 //拖拽模式，0或者1
            ,content: '${base}/admin/shoppingOrder/oddNumber.html?id='+id

        });
    }
    function showKD(id) {
         window.location.href="${base}/admin/shoppingOrder/kd.html?kd="+id
    }
    
    
    //删除
    function onDelete(id) {
        layer.confirm('真的要删除吗?', function (index) {
            $.ajax({
                type: "POST",
                url: "${base}/admin/wheelPlanting/deleteById",
                data: {id: id},
                sync: false,
                success: function (data) {
                    if (data.code === 200) {
                        layer.msg(data.msg)
                        setTimeout(function () {
                            window.location.reload();
                        }, 500)
                    } else {
                        layer.msg(data.msg)
                    }

                }
            });
        });
    }
    function sech() {
        var whereData = {}
        whereData.oddNumber = $("#oddNumber").val();
        whereData.phone = $("#phone").val();
        whereData.state = $("#state").val();
        whereData.type = $("#type").val();
        //表刷新方法
        var table = layui.table;
        table.reload('testReload', {
            url: '${base}/admin/shoppingOrder/selectMyPage'
            , where: whereData
        });
    }
</script>

</body>

</html>


